﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleUI
{
    public class CardHelper
    {
        /// <summary>
        /// 生成count服牌
        /// </summary>
        /// <param name="count"></param>
        /// <param name="random">是否打乱</param>
        /// <returns></returns>
        public static List<Card> IniCard(int count, bool random = true)
        {
            List<Card> cards = new List<Card>();
            for (int k = 0; k < count; k++)
            {
                for (int i = 1; i <= 13; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        cards.Add(new Card { Color = j, Name = i, Type = 1 });
                    }
                }
                //cards.Add(new Card { Type = 3 });
                //cards.Add(new Card { Type = 2 });
            }
            if (random)
            {
                cards = Utils.RandomSort(cards);
            }
            return cards;
        }
        public static object[] SendCard(List<Card> cards, int count = 2)
        {
            //每个人分几个牌
            var retval = new object[count];
            var x = cards.Count / count;
            for (int i = 0; i < count; i++)
            {
                retval[i] = cards.Skip(x * i).Take(x).ToList();
            }
            return retval;
        }
    }
}
